<h1>Authorization Usage</h1>
<%= render 'authorization_rules/show_graph' %>
<p>Filter rules in actions by controller:</p>
<p><%= navigation %></p>
<style type="text/css">
  .auth-usages th { text-align: left; padding-top: 1em }
  .auth-usages td { padding-right: 1em }
  .auth-usages tr.action  { cursor: pointer }
  .auth-usages tr.unprotected  { background: #FFA399 }
  .auth-usages tr.no-attribute-check { background: #FFE599 }
  /*.auth-usages tr.catch-all td.privilege,*/
  .auth-usages tr.default-privilege td.privilege,
  .auth-usages tr.default-context td.context { color: #888888 }
  #graph-container {margin: 1em; border:1px solid #ccc; max-width:50%; position:fixed; right:0;}
</style>
<table class="auth-usages">
  <% @auth_usages_by_controller.keys.sort {|c1, c2| c1.name <=> c2.name}.each do |controller| %>
    <% default_context = controller.controller_name.to_sym rescue nil %>
    <tr>
      <th colspan="3"><%= h controller.controller_name %></th>
    </tr>
    <% @auth_usages_by_controller[controller].keys.sort {|c1, c2| c1.to_s <=> c2.to_s}.each do |action| %>
      <% auth_info = @auth_usages_by_controller[controller][action] %>
      <% first_permission = auth_info[:controller_permissions] && auth_info[:controller_permissions][0] %>
      <tr class="action <%= auth_usage_info_classes(auth_info) %>" title="<%= auth_usage_info_title(auth_info) %>" onclick="show_graph('<%= auth_info[:privilege] || action %>','<%= auth_info[:context] || default_context %>')">
        <td><%= h action %></td>
        <% if first_permission %>
          <td class="privilege"><%= h auth_info[:privilege] || action %></td>
          <td class="context"><%= h auth_info[:context] || default_context %></td>
        <% else %>
          <td></td><td></td>
        <% end %>
      </tr>
    <% end %>
  <% end %>
</table>
